/*
 * Package il.ac.biu.cs.grossmm.impl.server
 * File Association.java
 * 
 * This is a part of presence service framework prototype. 
 * See javadoc for more information.
 *  
 * Copyright (C) 2006 Grossmann Mark
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public License
 * as published by the Free Software Foundation; either version 2
 * of the License, or (at your option) any later version.
 *
 * This program is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 * GNU Lesser General Public License for more details.

 * You should have received a copy of the GNU Lesser General Public License
 * along with this program; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
 */

package il.ac.biu.cs.grossmm.impl.server;

import java.util.HashSet;

/**
 * An association is a directed link between two nodes, represented by
 * <tt>Node<T></tt> objects. This link leaves a node called "user" and enters
 * a node called "used". The link is associatded with a set of names, also
 * called "hints", and represented by <tt>java.lang.Object</tt>.
 * <p>
 * Altogether nodes and associations form a directed graph (which may contain
 * loops and cycles), where each link has one or more names.
 */
public class Association<T extends Node<T>> extends HashSet<Object> {
    private static final long serialVersionUID = -1174937076174786379L;

    /**
     * The "user" node 
     */
    T user;

    /**
     * The "used" node
     */
    T used;

    /**
     * Constructs a new association with a single hint
     * 
     * @param user the "user" node 
     * @param used the "used" node
     * @param hint the hint 
     */
    public Association(T user, T used, Object hint) {
        this.user = user;
        this.used = used;

        add(hint);
    }

    /**
     * Gets the "user" node
     * @return the "user" node
     */
    T getUser() {
        return user;
    }

    /**
     * Gets the "used" node
     * @return the "used" node
     */
    T getUsed() {
        return used;
    }
}
